#ifndef _C_WINDOW_BUFFER
#define _C_WINDOW_BUFFER

#include <stdint.h>
/*
* Window Buffer is a window buffer with data caching
*               window          buffer
*  ...______[0123456789abcdefgh|012345]___ ...
*            |                |      |
*          first              last   last_buff
*/
class cWindowBuffer
{
  public:
    cWindowBuffer(int window_size,int buffer_size);
    ~cWindowBuffer();
    void clear();
    int get_window_length();
    int get_buffer_length();
    int get_window_size();
    int get_buffer_size();    
    void flush_buffer();
    void insert(uint8_t val);
    void buffer(uint8_t val);
    uint8_t & operator[](const unsigned int index);
    uint8_t & operator()(const unsigned int index);
    void clear_buffer();
  private:
    int window_size;
    int window_len;
    int buffer_size;  
    int buffer_len;
    int first;
    int last;
    int last_buff;
    int total_size;
    uint8_t * data;
};

#endif //_C_WINDOW_BUFFER